package mysql

import (
	"gorm.io/gorm"
)

type Order struct {
	gorm.Model
	UserId   int     `gorm:"type:int;not null;comment:用户id"`
	OrderNum string  `gorm:"type:varchar(50);comment:订单号"`
	PayType  int     `gorm:"type:tinyint;default:1;not null;comment:支付方式:1.支付宝,2.微信"`
	PayState int     `gorm:"type:tinyint;default:1;not null;comment:支付方式:1.待支付,2.已支付,3.已退款,4.已完成"`
	PayPrice float64 `gorm:"type:decimal(10,2);not null;comment:订单金额"`
	PayTime  string  `gorm:"type:varchar(70);not null;comment:订单支付时间"`
}

type OrderGood struct {
	gorm.Model
	OrderId   int     `gorm:"type:int;not null;comment:订单id"`
	GoodId    int     `gorm:"type:int;not null;comment:商品id"`
	OrderName string  `gorm:"type:varchar(15);not null;comment:商品名称"`
	OrderNum  int     `gorm:"type:int;not null;comment:商品购买数量"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品单价"`
	GoodLike  int64   `gorm:"type:int;not null;comment:商品收藏"`
}

func (o *Order) Create() error {
	return DB.Create(&o).Error
}

func (og *OrderGood) Create() error {
	return DB.Create(&og).Error
}
